﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Administrator
{
    public partial class ucJoinLineLosts : UserControl
    {
        private Boolean LoadSetting = false;

        public Double LineLength = 0;
        public Double Resistance = 0;
        public Double UNominal = 0;
        public Double CableLost = 0;
        public Double AirLost = 0;
        public Int32 CircuitsAmount = 0;        

        public ucJoinLineLosts()
        {
            InitializeComponent();
        }

        //Заполнение структуры настроек и полей формы
        public void FillSetting(Double CLLLineLength, Double CLLResistance, Double CLLUNominal, Double CLLCableLost, Double CLLAirLost, Int32 CLLCircuitsAmount)
        {
            LineLength = CLLLineLength;
            Resistance = CLLResistance;
            UNominal = CLLUNominal;
            CableLost = CLLCableLost;
            AirLost = CLLAirLost;
            CircuitsAmount = CLLCircuitsAmount;

            if (CircuitsAmount <= 0) CircuitsAmount = 1;

            LoadSetting = true;
            nudLineLength.Value = (Decimal)LineLength;
            nudResistance.Value = (Decimal)Resistance;
            nudUNominal.Value = (Decimal)UNominal;
            nudCableLost.Value = (Decimal)CableLost;
            nudAirLost.Value = (Decimal)AirLost;
            nudCircuitsAmount.Value = (Decimal)CircuitsAmount;
            LoadSetting = false;
        }

        private void nudLineLength_ValueChanged(object sender, EventArgs e)
        {
            if (!LoadSetting)
            {
                if (sender == nudLineLength) LineLength = (Double)nudLineLength.Value;
                if (sender == nudResistance) Resistance = (Double)nudResistance.Value;
                if (sender == nudUNominal) UNominal = (Double)nudUNominal.Value;
                if (sender == nudCableLost) CableLost = (Double)nudCableLost.Value;
                if (sender == nudAirLost) AirLost = (Double)nudAirLost.Value;
                if (sender == nudCircuitsAmount) CircuitsAmount = (Int32)nudCircuitsAmount.Value;
            }
        }
    }
}
